<template>
  <div class="right">
    <div class="top">
      <div class="title">寻人启事</div>
      <a href="javascript:;" class="more" @click="goMore">更多>>></a>
    </div>
    <div class="box">
      <div class="items" v-for="(item, index) in loserInfos" :key="index" @click="details(item)">
        <div href="#" class="items-left">
          <img :src="item.l_photos" alt="" />
        </div>
        <div class="items-right">
          <div class="name">{{item.l_name}}</div>
          <div class="detail">
            {{item.l_descript}}
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script lang="ts" setup>
import { onMounted, ref } from 'vue';
import { useRouter } from 'vue-router'
import { getLoser } from '@/server/loser'

const router = useRouter()
const loserInfos = ref<any>([])

onMounted(async () => {
  await getLoserList()
})

const getLoserList = () => {
  getLoser().then((res:any) => {
    loserInfos.value = res.data.splice(0,3)
  })
}

const goMore = () => {
  router.push('/LoserInfos')
}
const details = (item:any) => {
  router.push({
    path:'/LoserDetail',
    query:{
      id:item.id
    }
  })
  
}
</script>

<style lang="less" scoped>
.right {
  height: 360px;
  width: 28%;
  background-color: #eee;
  border-radius: 10px;
  padding: 10px;
  .top {
    display: flex;
    align-items: center;
    font-size: 24px;
    .title {
      color: red;
      font-weight: bolder;
    }
    .more {
      font-size: 12px;
      margin-left: 5px;
    }
  }
  .box {
    // background-color: pink;
    .items {
      display: flex;
      margin: 20px 0;
      height: 80px;
      &-left {
        width: 28%;
        margin-right: 5px;
        img {
          border-radius: 10px;
          width: 100%;
          height: 100%;
        }
      }
      &-right {
        flex: 1;
        display: flex;
        flex-direction: column;
        font-size: 16px;
        .name {
          font-weight: bolder;
        }
        .detail {
          text-overflow: -o-ellipsis-lastline;
          overflow: hidden;
          text-overflow: ellipsis;
          display: -webkit-box;
          -webkit-line-clamp: 3;
          line-clamp: 3;
          -webkit-box-orient: vertical;
          font-size: 12px;
        }
      }
    }
    .items:hover{
      cursor: pointer;
    }
  }
}
</style>
